<?php
    $this->pageTitle = Yii::t('vcos','wifi配置模式列表');
    $theme_url = Yii::app()->theme->baseUrl;
    
    $menu_type =  'wifi_config_list';
?>
<?php 
    //navbar 挂件
    $this->widget('navbarWidget');
    if(in_array('50', $auth) || $auth[0] == '0'){
    	$canadd = TRUE;
    }  else {
    	$canadd = False;
    }
    if(in_array('51', $auth) || $auth[0] == '0'){
    	$canedit = TRUE;
    }  else {
    	$canedit = False;
    }
    if(in_array('275', $auth) || $auth[0] == '0'){
    	$candelete = TRUE;
    }  else {
    	$candelete = FALSE;
    }
?>     
<div class="main-container" id="main-container">
        <script type="text/javascript">
			try{ace.settings.check('main-container' , 'fixed')}catch(e){}
        </script>

        <div class="main-container-inner">
                <a class="menu-toggler" id="menu-toggler" href="#">
                        <span class="menu-text"></span>
                </a>
                <?php
                //菜单挂件
                 $this->widget('menuWidget', array('menu_type'=>$menu_type));
                ?>
                <div class="main-content"> 
                    <?php
                        //面包屑挂件
                        $this->widget('breadcrumbWidget');
                    ?>
                    <div class="page-content">
                        <div class="page-header">
                            <h1>
                                <?php echo yii::t('vcos', '网络通信管理')?>
                                <small>
                                    <i class="icon-double-angle-right"></i>
                                    <?php echo yii::t('vcos', 'wifi配置模式列表')?>
                                </small>
                            </h1>
                        </div><!-- /.page-header -->
                        <div class="row">
                            <div class="col-xs-12"><!-- PAGE CONTENT BEGINS -->
                                <div class="row">
                                    <div class="col-xs-12">
                                        <div class="table-responsive">
                                            <form method="post" name="save" action="">
                                            <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                    	<th class="center">
                                                            <label>
                                                                <input type="checkbox" class="ace" />
                                                                <span class="lbl"></span>
                                                            </label>
                                                        </th>
                                                        <th><?php echo yii::t('vcos', '模式说明')?></th>
                                                        <th><?php echo yii::t('vcos', '登陆网址')?></th>
                                                        <th><?php echo yii::t('vcos', '主动登出网址')?></th>
                                                        <th><?php echo yii::t('vcos', '改变时长')?></th>
                                                        <th><?php echo yii::t('vcos', '被动登出网址')?></th>
                                                        <th><?php echo yii::t('vcos', '政策')?></th>
                                                        <th><?php echo yii::t('vcos', 'SSID')?></th>
                                                        <th><?php echo yii::t('vcos', 'ACIP')?></th>
                                                        <th><?php echo yii::t('vcos', 'APMAC')?></th>
                                                        <th><?php echo yii::t('vcos', '状态')?></th>
                                                        <th><?php echo yii::t('vcos', '操作')?></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php foreach ($wifi as $key=>$row) { ?>
                                                    <tr>
                                                    	<td class="center">
                                                           <label>
                                                               <input type="checkbox" name="ids[]" value="<?php echo $row['config_id'];?>" class="ace isclick" />
                                                               <span class="lbl"></span>
                                                           </label>
                                                        </td>
                                                        <td><?php echo $row['config_describe'];?></td>
                                                        <td><?php echo $row['config_login_url'];?></td>
                                                        <td><?php echo $row['config_logout_url'];?></td>
                                                        <td><?php echo $row['config_change_url'];?></td>
                                                        <td><?php echo $row['config_notice'];?></td>
                                                        <td><?php echo $row['config_policy'];?></td>
                                                        <td><?php echo $row['config_ssid'];?></td>
                                                        <td><?php echo $row['config_acip'];?></td>
                                                        <td><?php echo $row['config_apmac'];?></td>
                                                        <td>
                                                            <label>
                                                                <input type="checkbox" <?php if($row['config_state']){echo 'checked="checked"';}?> class="ace ace-switch ace-switch-5 wifi-state" name="state" value=<?php echo $row['config_id'];?> />
                                                                <span class="lbl"></span>
                                                            </label>
                                                        </td>
                                                        <td>
                                                            <?php
                                                                    //操作挂件
                                                                    $this->widget('ManipulateWidget',array(
                                                                        'ControllerName'=>'Wifisetting',
                                                                        'MethodName'=>'wifi_config_edit',
                                                                        'id'=>$row['config_id'],
                                                                        'canedit'=>$canedit,
                                                                        'candelete'=>$candelete,
                                                                    ));
                                                                ?>
                                                        </td>
                                                    </tr>
                                                    <?php }?>
                                                </tbody>
                                            </table>
                                       		
                                            </form>
                                            	<div class="center">
                                            	<button id="wifi_state" val="" class="btn btn-xs btn-warning" >
                                                    <i class="icon-print bigger-125"></i>
                                                    <span class="bigger-110 no-text-shadow"><?php echo yii::t('vcos', '保存选项')?></span>
                                                </button>
                                                    <?php
                                                        //底部操作挂件
                                                        $this->widget('BotWidget',array(
                                                            'ControllerName'=>'Wifisetting',
                                                            'MethodName'=>'Wifi_config_add',
                                                            'canadd'=>$canadd,
                                                            'candelete'=>$candelete,
                                                        ));
                                                    ?>
                                             	</div>
                                                <div class="center">
                                                    <?php
                                                    $this->widget('MyCLinkPager',array(
                                                        'pages'=>$pages,
                                                        'header'=>false,
                                                        'htmlOptions'=>array('class'=>'pagination'),
                                                        'firstPageLabel'=>yii::t('vcos', '首页'),
                                                        'lastPageLabel'=>yii::t('vcos', '尾页'),
                                                        'prevPageLabel'=>'«',
                                                        'nextPageLabel'=>'»',
                                                        'maxButtonCount'=>5,
                                                        'cssFile'=>false,
                                                        ));
                                                    ?>
                                                </div>
                                        </div><!-- /.table-responsive -->
                                    </div><!-- /span -->
                                </div><!-- /row -->
                            </div><!-- /.col -->
                        </div><!-- /.row -->
                    </div><!-- /.page-content -->
                </div><!-- /.main-content -->
                <!-- /#ace-settings-container start-->
                <?php
                    //设置容器配置挂件
                    $this->widget('settingsContainerWidget');
                ?>
                <!-- /#ace-settings-container end-->
        </div><!-- /.main-container-inner -->
        
        <!-- scrool up widget start-->
        <?php
            $this->widget('scrollUpWidget');
        ?>
        <!-- scrool up widget end-->
        
</div><!-- /.main-container -->
				<?php
                    //删除确认框
                    $this->widget('ConfirmWidget',array(
                        'div_id'=>'dialog-confirm',
                        'title_content'=>yii::t('vcos', '这条记录将被永久删除，并且无法恢复。'),
                    ));
                ?>
                <?php
                    //批量删除确认框
                    $this->widget('ConfirmWidget',array(
                        'div_id'=>'dialog-confirm-multi',
                        'title_id'=>'isempty1',
                        'title_content'=>yii::t('vcos', '这些选中的记录将被永久删除，并且无法恢复。'),
                        'confirm_id'=>'isempty2',
                    ));
                ?>
<!-- basic scripts -->

<!--[if !IE]> -->

<script type="text/javascript">
        window.jQuery || document.write("<script src='<?php echo $theme_url; ?>/assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<?php echo $theme_url; ?>/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

<script type="text/javascript">
        if("ontouchend" in document) document.write("<script src='<?php echo $theme_url; ?>/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="<?php echo $theme_url; ?>/assets/js/bootstrap.min.js"></script>
<script src="<?php echo $theme_url; ?>/assets/js/jquery-ui-1.10.3.full.min.js"></script>
<script type="text/javascript">
jQuery(function($) {
    $(".wifi-state").on('click' , function(){
        $(".wifi-state").prop("checked",false);
        $(this).prop("checked",true);
        var val = $(this).val();
        $("#wifi_state").attr('val',val);
        
    });
	/*保存选项**/
	$("#wifi_state").click(function(){
		var val = $(this).attr('val');
	    var url = "<?php echo Yii::app()->createUrl("Wifisetting/wifi_config_set_state")?>";
	    if(val != ''){
		   $.ajax({
		     url:url,
		     data:'id='+val,
		     success:function(msg){
			    if(msg){
				    alert("<?php echo yii::t('vcos', '保存成功')?>");
			    }else{
				alert("<?php echo yii::t('vcos', '保存失败')?>");
				    }
		     }
		   });
	    }
	});
});

</script>
<script type="text/javascript">
jQuery(function($) {
    $('table th input:checkbox').on('click' , function(){
        var that = this;
        $(this).closest('table').find('tr > td:first-child input:checkbox')
        .each(function(){
            this.checked = that.checked;
            $(this).closest('tr').toggleClass('selected');
        });

    });    
    $.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
    _title: function(title) {
        var $title = this.options.title || '&nbsp;'
        if( ("title_html" in this.options) && this.options.title_html == true )
            title.html($title);
        else title.text($title);
        }
    }));
    $( ".delete" ).on('click', function(e) {
        var $a = $(this).attr("id");
        e.preventDefault();
        $( "#dialog-confirm" ).removeClass('hide').dialog({
            closeOnEscape:false, 
            open:function(event,ui){$(".ui-dialog-titlebar-close").hide();} ,
            resizable: false,
            modal: true,
            title: "<div class='widget-header'><h4 class='smaller'><i class='icon-warning-sign red'></i><?php echo yii::t('vcos', '删除这条记录？')?></h4></div>",
            title_html: true,
            buttons: [
                {
                    html: "<i class='icon-trash bigger-110'></i>&nbsp; <?php echo yii::t('vcos', '删除？')?>",
                    "class" : "btn btn-danger btn-xs ",
                    click: function() {
                        location.href="<?php echo Yii::app()->createUrl("Wifisetting/wifi_config_list");?>"+"?id="+$a;
                        $( this ).dialog( "close" );
                    }
                }
                ,
                {
                    html: "<i class='icon-remove bigger-110'></i>&nbsp; <?php echo yii::t('vcos', '取消？')?>",
                    "class" : "btn btn-xs ",
                    click: function() {
                        $( this ).dialog( "close" );
                    }
                }
            ]
        });
    });  
    $( "#submit" ).on('click', function(e) {
        e.preventDefault();
        $( "#dialog-confirm-multi").removeClass('hide').dialog({
            closeOnEscape:false, 
            open:function(event,ui){$(".ui-dialog-titlebar-close").hide();} ,
            resizable: false,
            modal: true,
            title: "<div class='widget-header'><h4 class='smaller'><i class='icon-warning-sign red'></i><?php echo yii::t('vcos', '删除选中的记录？')?></h4></div>",
            title_html: true,
            buttons: [
                {
                    html: "<i class='icon-trash bigger-110'></i>&nbsp; <?php echo yii::t('vcos', '删除？')?>",
                    "class" : "btn btn-danger btn-xs ",
                    "id" :"danger2",
                    click: function() {
                        $("form:first").submit();
                        $( this ).dialog( "close" );
                    }
                }
                ,
                {
                    html: "<i class='icon-remove bigger-110'></i>&nbsp; <?php echo yii::t('vcos', '取消？')?>",
                    "class" : "btn btn-xs ",
                    click: function() {
                        $('#danger2').show();
                        $('.widget-header h4').html("<i class='icon-warning-sign red'></i><?php echo yii::t('vcos', '删除选中的记录！')?>");
                        $('#isempty1').html("<?php echo yii::t('vcos', '这些选中的记录将被永久删除，并且无法恢复。')?>");
                        $('#isempty2').show();
                        $( this ).dialog( "close" );
                    }
                }
            ]
        });
        if(!$('.isclick').is(':checked')){
            $('#danger2').hide();
            $('.widget-header h4').html("<i class='icon-warning-sign red'></i><?php echo yii::t('vcos', '没有选中！')?>");
            $('#isempty1').html("<?php echo yii::t('vcos', '请选择删除项。')?>");
            $('#isempty2').hide();
        }
    }); 
});
</script>
